package com.project.web.controller.user;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.project.user.domain.UserGoodsPrefer;
import com.project.user.service.IUserGoodsPreferService;
import com.project.web.controller.common.BaseController;
import com.project.common.base.TableDataInfo;
import com.project.common.base.AjaxResult;

/**
 * 用户收藏餐饮关联 信息操作处理
 *
 * @author administrator
 */
@Controller
@RequestMapping("/user/userGoodsPrefer")
public class UserGoodsPreferController extends BaseController {
    private String prefix = "user/userGoodsPrefer";

    @Autowired
    private IUserGoodsPreferService userGoodsPreferService;

    @GetMapping()
    public String userGoodsPrefer() {
        return prefix + "/userGoodsPrefer";
    }

    /**
     * 查询用户收藏餐饮关联列表
     *
     * @param userGoodsPrefer
     * @return
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(UserGoodsPrefer userGoodsPrefer) {
        userGoodsPrefer.setUserId(this.getUserId());
        startPage();
        List<UserGoodsPrefer> list = userGoodsPreferService.selectUserGoodsPreferList(userGoodsPrefer);
        return getDataTable(list);
    }

    /**
     * 新增保存用户收藏餐饮关联
     *
     * @param userGoodsPrefer
     * @return
     */
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(UserGoodsPrefer userGoodsPrefer) {
        userGoodsPrefer.setUserId(this.getUserId());
        return toAjax(userGoodsPreferService.insertUserGoodsPrefer(userGoodsPrefer));
    }

    /**
     * 删除用户收藏餐饮关联
     *
     * @param userGoodsPrefer
     * @return
     */
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(UserGoodsPrefer userGoodsPrefer) {
        userGoodsPrefer.setUserId(this.getUserId());
        return toAjax(userGoodsPreferService.deleteUserGoodsPrefer(userGoodsPrefer));
    }

}
